/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "PERSONA", catalog = "", schema = "PROYECTO")
@NamedQueries({
    @NamedQuery(name = "Persona.findAll", query = "SELECT p FROM Persona p"),
    @NamedQuery(name = "Persona.findByCodigopersona", query = "SELECT p FROM Persona p WHERE p.codigopersona = :codigopersona"),
    @NamedQuery(name = "Persona.findByContrasenia", query = "SELECT p FROM Persona p WHERE p.contrasenia = :contrasenia"),
    @NamedQuery(name = "Persona.findByRegistro", query = "SELECT p FROM Persona p WHERE p.registro = :registro"),
    @NamedQuery(name = "Persona.findByEscarapela", query = "SELECT p FROM Persona p WHERE p.escarapela = :escarapela"),
    @NamedQuery(name = "Persona.findByCertificado", query = "SELECT p FROM Persona p WHERE p.certificado = :certificado"),
    @NamedQuery(name = "Persona.findByRecuerdos", query = "SELECT p FROM Persona p WHERE p.recuerdos = :recuerdos"),
    @NamedQuery(name = "Persona.findByNombre", query = "SELECT p FROM Persona p WHERE p.nombre = :nombre")})
public class Persona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "CODIGOPERSONA", nullable = false)
    private Integer codigopersona;
    @Column(name = "CONTRASENIA", length = 20)
    private String contrasenia;
    @Basic(optional = false)
    @Column(name = "REGISTRO", nullable = false)
    private char registro;
    @Basic(optional = false)
    @Column(name = "ESCARAPELA", nullable = false)
    private char escarapela;
    @Column(name = "CERTIFICADO")
    private Character certificado;
    @Column(name = "RECUERDOS")
    private Character recuerdos;
    @Column(name = "NOMBRE", length = 250)
    private String nombre;
    @JoinTable(name = "ROLPERSONA", joinColumns = {
        @JoinColumn(name = "PERSONA_CODIGOPERSONA", referencedColumnName = "CODIGOPERSONA", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "ROL_CODIGO", referencedColumnName = "CODIGO", nullable = false)})
    @ManyToMany(fetch = FetchType.EAGER)
    private List<Rol> rolList;
    @JoinTable(name = "PREMIOPERSONA", joinColumns = {
        @JoinColumn(name = "PERSONA_CODIGOPERSONA", referencedColumnName = "CODIGOPERSONA", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "PREMIOS_CODIGO", referencedColumnName = "CODIGO", nullable = false)})
    @ManyToMany(fetch = FetchType.EAGER)
    private List<Premios> premiosList;
    @JoinColumn(name = "CODIGOUNIDADORGANIZACIONAL", referencedColumnName = "CODIGOUNIDAD", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Unidadorganizacional unidadorganizacional;
    @JoinColumn(name = "TIPO_IDTIPO", referencedColumnName = "IDTIPO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Tipo tipo;
    @JoinColumn(name = "CODIGOPERSONA", referencedColumnName = "CODIGO", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.EAGER)
    private Quien quien;
    @OneToMany(mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Persona> personaList;
    @JoinColumn(name = "PERSONA_CODIGOPERSONA", referencedColumnName = "CODIGOPERSONA")
    @ManyToOne(fetch = FetchType.EAGER)
    private Persona persona;
    @JoinColumn(name = "PAIS_CODIGO", referencedColumnName = "CODIGO", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Pais pais;
    @OneToMany(mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Programacion> programacionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Estudiopersona> estudiopersonaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Carta> cartaList;
    @OneToOne(mappedBy = "persona", fetch = FetchType.EAGER)
    private Registro registro1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Libros> librosList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Items> itemsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Articulo> articuloList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "persona", fetch = FetchType.EAGER)
    private List<Actividades> actividadesList;

    public Persona() {
    }

    public Persona(Integer codigopersona) {
        this.codigopersona = codigopersona;
    }

    public Persona(Integer codigopersona, char registro, char escarapela) {
        this.codigopersona = codigopersona;
        this.registro = registro;
        this.escarapela = escarapela;
    }

    public Integer getCodigopersona() {
        return codigopersona;
    }

    public void setCodigopersona(Integer codigopersona) {
        this.codigopersona = codigopersona;
    }

    public String getContrasenia() {
        return contrasenia;
    }

    public void setContrasenia(String contrasenia) {
        this.contrasenia = contrasenia;
    }

    public char getRegistro() {
        return registro;
    }

    public void setRegistro(char registro) {
        this.registro = registro;
    }

    public char getEscarapela() {
        return escarapela;
    }

    public void setEscarapela(char escarapela) {
        this.escarapela = escarapela;
    }

    public Character getCertificado() {
        return certificado;
    }

    public void setCertificado(Character certificado) {
        this.certificado = certificado;
    }

    public Character getRecuerdos() {
        return recuerdos;
    }

    public void setRecuerdos(Character recuerdos) {
        this.recuerdos = recuerdos;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public List<Rol> getRolList() {
        return rolList;
    }

    public void setRolList(List<Rol> rolList) {
        this.rolList = rolList;
    }

    public List<Premios> getPremiosList() {
        return premiosList;
    }

    public void setPremiosList(List<Premios> premiosList) {
        this.premiosList = premiosList;
    }

    public Unidadorganizacional getUnidadorganizacional() {
        return unidadorganizacional;
    }

    public void setUnidadorganizacional(Unidadorganizacional unidadorganizacional) {
        this.unidadorganizacional = unidadorganizacional;
    }

    public Tipo getTipo() {
        return tipo;
    }

    public void setTipo(Tipo tipo) {
        this.tipo = tipo;
    }

    public Quien getQuien() {
        return quien;
    }

    public void setQuien(Quien quien) {
        this.quien = quien;
    }

    public List<Persona> getPersonaList() {
        return personaList;
    }

    public void setPersonaList(List<Persona> personaList) {
        this.personaList = personaList;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    public Pais getPais() {
        return pais;
    }

    public void setPais(Pais pais) {
        this.pais = pais;
    }

    public List<Programacion> getProgramacionList() {
        return programacionList;
    }

    public void setProgramacionList(List<Programacion> programacionList) {
        this.programacionList = programacionList;
    }

    public List<Estudiopersona> getEstudiopersonaList() {
        return estudiopersonaList;
    }

    public void setEstudiopersonaList(List<Estudiopersona> estudiopersonaList) {
        this.estudiopersonaList = estudiopersonaList;
    }

    public List<Carta> getCartaList() {
        return cartaList;
    }

    public void setCartaList(List<Carta> cartaList) {
        this.cartaList = cartaList;
    }

    public Registro getRegistro1() {
        return registro1;
    }

    public void setRegistro1(Registro registro1) {
        this.registro1 = registro1;
    }

    public List<Libros> getLibrosList() {
        return librosList;
    }

    public void setLibrosList(List<Libros> librosList) {
        this.librosList = librosList;
    }

    public List<Items> getItemsList() {
        return itemsList;
    }

    public void setItemsList(List<Items> itemsList) {
        this.itemsList = itemsList;
    }

    public List<Articulo> getArticuloList() {
        return articuloList;
    }

    public void setArticuloList(List<Articulo> articuloList) {
        this.articuloList = articuloList;
    }

    public List<Actividades> getActividadesList() {
        return actividadesList;
    }

    public void setActividadesList(List<Actividades> actividadesList) {
        this.actividadesList = actividadesList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigopersona != null ? codigopersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persona)) {
            return false;
        }
        Persona other = (Persona) object;
        if ((this.codigopersona == null && other.codigopersona != null) || (this.codigopersona != null && !this.codigopersona.equals(other.codigopersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Persona[codigopersona=" + codigopersona + "]";
    }

}
